package com.composite.pattern;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenchen
 * @description
 * @date 2023/11/10 13:46
 */
public class Department extends Component {

    public Department(String name, String describe) {
        super(name, describe);
    }

    //管理部门下的员工，也就是部门下的子节点
    private final List<Component> components = new ArrayList<>();

    @Override
    public void show() {
        System.out.println("名称：" + getName() + "，描述：" + getDescribe());
        for (Component component : components) {
            component.show();
        }
    }

    @Override
    public void add(Component component) {
        components.add(component);
    }

    @Override
    public void remove(Component component) {
        components.remove(component);
    }
}
